package com.ruanhb.wsp.service;

import com.alibaba.fastjson.JSON;
import com.ruanhb.wsp.vo.BaseResponse;
import com.ruanhb.wsp.vo.Weather;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by r on 2018-9-21
 */
@Service
public class WeatherReportServiceImpl implements WeatherReportService {

    @Autowired
    private DataClient dataClient;

    @Override
    public Weather getWeatherDataByCityId(String cityId) {
        BaseResponse baseResponse = dataClient.getDataByCityId(cityId);
        if (baseResponse==null)
            return null;
        return JSON.parseObject(JSON.toJSONString(baseResponse.getData()),Weather.class);
    }
}
